"""
Author: wenbin
Create: 2024-08-17
"""
import uuid

from sqlalchemy import Column, UUID, Index, String
from sqlalchemy.dialects.postgresql import JSONB

from .base_model import BaseModel
from ..enums import MemoryMode, ConfigType


class AppConfig(BaseModel):
    """应用配置模型"""

    __tablename__ = 'app_config'
    __table_args__ = (
        Index("idx_app_config_app_id", "app_id"),
        {"comment": "应用配置表"}
    )

    id = Column(UUID, default=uuid.uuid4, primary_key=True, comment="id")
    app_id = Column(UUID, nullable=False, comment="应用 id")
    model_config = Column(JSONB, nullable=False, comment="模型配置")
    memory_mode = Column(String(20), nullable=False, default=MemoryMode.NONE.value, comment="记忆模式")
    type = Column(String(20), nullable=False, default=ConfigType.DRAFT.value, comment="配置类型")
